<!DOCTYPE XHTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>NPAPI File IO test</title>
  <script type="text/javascript" src="../../../closure/base.js"></script>
	<script type="text/javascript" src="../common.js"></script>
  <script type="text/javascript">
	goog.require('goog.testing.jsunit');
	</script>
</head>
<body>
  <h1 style="color: red">Assumes fileExists works</h1>
	<script type="text/javascript">
  function testCanMkdirWithTrailingSlash() {
    var subdir = getPath("subdir" + getRandom() + getPlatformSlash());
    plugin.createDirectory(subdir);
    assertTrue(plugin.fileExists(subdir));
  }
  
  function testCanMkdirWithoutTrailingSlash() {
    var subdir = getPath("subdir" + getRandom());
    plugin.createDirectory(subdir);
    assertTrue(plugin.fileExists(subdir));
  }
  
  function testCanMkdirRecursivelyWithoutTrailingSlash() {
    var subdir = getPath("subdir" + getRandom() + getPlatformSlash() + "foo" + getPlatformSlash() + "bar");
    plugin.createDirectory(subdir);
    assertTrue(plugin.fileExists(subdir));
  }
  
  function testCanMkdirRecursivelyWithTrailingSlash() {
    var subdir = getPath("subdir" + getRandom() + getPlatformSlash() + "foo" + getPlatformSlash() + "bar" + getPlatformSlash());
    plugin.createDirectory(subdir);
    assertTrue(plugin.fileExists(subdir));
  }
  
  function testMkdirThrowsForExistingDirectory() {
    assertThrows(function() { plugin.createDirectory(getPath("subdir-exists")) });
  }
  
  function testMkdirThrowsForExistingFile() {
    assertThrows(function() { plugin.createDirectory(getPath("exists.txt")) });
  }
	</script>
</body>
</html>
